/**
 * 
 */
package belote.webapp.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

/**
 * @author Gwenn
 *
 */
public class ProfilServlet extends HttpServlet {

	private static final long serialVersionUID = -2264411369315120900L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		UserService userService = UserServiceFactory.getUserService();
		User utilisateur = userService.getCurrentUser();
		
		if (utilisateur != null) {
			resp.getWriter().println(utilisateur.getUserId() + "<br/>");
			resp.getWriter().println(utilisateur.getNickname() + "<br/>");
			resp.getWriter().println(utilisateur.getEmail() + "<br/>");
			
			resp.getWriter().println("<p>Hello, " +
                    req.getUserPrincipal().getName() +
                    "!  You can <a href=\"" +
                    userService.createLogoutURL(req.getRequestURI()) +
                    "\">sign out</a>.</p>");

			
		} else {
			resp.getWriter().println("Utilisateur inconnu !!!");
		}
	}
}
